<include file="Core:Public:header" />
{:W('Navigation')}
<script src="__PUBLIC__/js/datepicker/WdatePicker.js"></script>
<div class="body-right">
	<div class="row-table">
		<div class="row-table-title">请假管理</div>
		<div class="row-table-body">
			<p class="form-title">请假管理<a href="{:U('hrm/leave/add')}" class="pull-right btn btn-primary btn-xs" >添加</a></p>
			<form id="search_form" action="" method="get">
				<input type="hidden" name="g" value="hrm"/>
				<input type="hidden" name="m" value="leave"/>
				<div class="form-inline" >
					<div class="form-group">
						<label for="search_user_name">请假人</label>
						<input type="text" class="form-control" id="search_user_name" name="search_user_name" placeholder="请输入全称..."/>
					</div>&nbsp;&nbsp;
					<div class="form-group">
						<label for="search_status">状态</label>
						<select class="form-control" id="search_status" name="search_status">
							<option value="">全部</option>
							<option value="0">处理中</option>
							<option value="1">已通过</option>
							<option value="2">未通过</option>
						</select>
					</div>&nbsp;&nbsp;
					<div class="form-group">
						<label for="search_category">类型</label>
						<select class="form-control" id="search_category" name="search_category">
							<option value="">全部</option>
							<option value="1">事假</option>
							<option value="2">病假</option>
							<option value="3">出差</option>
							<option value="4">婚假</option>
							<option value="5">产假</option>
							<option value="6">年假</option>
							<option value="7">丧假</option>
						</select>
					</div>&nbsp;&nbsp;
					<div class="form-group">
						<input type="text" class="form-control" id="search_start_time" name="search_start_time" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})" placeholder="开始日期"/>&nbsp;-&nbsp;
						<input type="text" class="form-control" id="search_end_time" name="search_end_time" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})" placeholder="结束日期"/>
					</div>
					<input type="button" class="btn search_btn" value="搜索" />
				</div>
			</form>
			<if condition="empty($leavelist)">
				<div>---暂无数据---</div>
			<else />
			<form class="form-horizontal " id="form1"  method="post">
				<table class="table" style="margin-bottom:0px;">
					<tbody>
						<tr>
							<th><input type="checkbox" name="leave_id[]" id="check_all"/></th>
							<th>请假人</th>
							<th>填写人</th>
							<th>状态</th>
							<th>请假类型</th>
							<th>请假时间</th>
							<th>天数</th>
							<th>小时</th>
							<th>创建时间</th>
							<th>操作</th>
						</tr>
						<volist name="leavelist" id="vo">
						<tr>
							<td><input type="checkbox" name="id[]" class="check_list" value="{$vo.leave_id}" /></td>
							<td>{$vo.user_name}</td>
							<td>{$vo.maker_user_name}</td>
							<td>
								<if condition="'0' eq $vo['status']">
									<span style="color:#F8971C">{$vo.status_name}</span>
								<elseif condition="'1' eq $vo['status']" />
									<span style="color:#0EB930">{$vo.status_name}</span>
								<else />
									<span style="color:#FF3908;">{$vo.status_name}</span>
								</if>
							</td>
							<td>{$vo.category_name}</td>
							<td>{$vo.start_time|date='Y-m-d H:i',###}&nbsp;至&nbsp;{$vo.end_time|date='Y-m-d H:i',###}</td>
							<td>{$vo.leave_days}</td>
							<td>{$vo.leave_hours}</td>
							<td>{$vo.create_time|date='Y-m-d H:i:s',###}</td>
							<td>
								<a href="{:U('hrm/leave/view','id='.$vo['leave_id'])}">查看</a>&nbsp;|&nbsp;
								<a href="{:U('hrm/leave/edit','id='.$vo['leave_id'])}">编辑</a>&nbsp;|&nbsp;
								<a href="{:U('hrm/leave/delete','id='.$vo['leave_id'])}">删除</a>
							</td>
						</tr>
						</volist>
					</tbody>
					<tfoot>
						<tr>
							<td colspan="6">
								<select name="status" id="select_status">
									<option value="0" selected="selected">处理中</option>
									<option value="1">已通过</option>
									<option value="2">未通过</option>
								</select>&nbsp;&nbsp;
								<input class="btn btn-primary btn-xs" type="submit" id="delete" value="删除"/>
							</td>
						</tr>
						<tr>
							<td colspan="6" align="center">{$page}<div class="clear"></div></td>
						</tr>
					</tfoot>
				</table>
			</form>
			</if>
		</div>
	</div>
</div>
<div class="clear"></div>
<script type="text/javascript">
	/**
	 * 全选
	 **/
	$("#check_all").click(function(){
		$("input[class='check_list']").prop('checked',$(this).prop('checked'));
	});
	
	/**
	 * 批量删除
	 **/
	$("#delete").click(function(){
		if(confirm('确定要删除吗？')){
			$("#form1").attr("action","{:U('hrm/leave/delete')}");
			$("#form1").submit();
		}
	});
	/**
	 * 批量审核
	 **/
	$("#select_status").change(function(){
		if(confirm('确定要批量审核吗？')){
			$("#form1").attr("action","{:U('hrm/leave/auditing')}");
			$("#form1").submit();
		}
	});
	
	$('#search_user_name').prop('value', '{$Think.get.search_user_name}');
	$('#search_status').prop('value', '{$Think.get.search_status}');
	$("#search_category option[value='{$Think.get.search_category}']").prop('selected', true);
	$('#search_start_time').prop('value', '{$Think.get.search_start_time}');
	$('#search_end_time').prop('value', '{$Think.get.search_end_time}');
	
	/**
	 * 单击提交搜索表单
	 * 双击清空搜索项
	 **/
	$(function(){
		var TimeFn = null;
		$('.btn.search_btn').click(function () {
			clearTimeout(TimeFn);
			TimeFn = setTimeout(function(){
				$('#search_form').submit();
			},300);
		});
		
		$('.btn.search_btn').dblclick(function () {
			clearTimeout(TimeFn);
			window.location.href="{:U('hrm/leave/index')}";
		})
	});
</script>
<include file="Core:Public:alert" />
<include file="Core:Public:footer" />